package com.yunxin.core.infra.persistence.mapper.merchant;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.yunxin.core.domain.model.team.UserTeamShip;
import com.yunxin.core.infra.persistence.entity.merchant.MerchantUserAccountDO;
import com.yunxin.core.infra.persistence.entity.merchant.query.result.MerchantAccountResult;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Set;

/**
 * @author zero°
 * @since 2023-06-06
 */
@DS("core")
@Mapper
public interface MerchantUserAccountExtendMapper extends MerchantUserAccountMapper {

    /**
     * 根据系统用户id查询商户用户
     * @param sysUserId sysUserId
     * @return MerchantUserAccount
     */
    MerchantUserAccountDO selectBySysUserId(@Param("sysUserId") Long sysUserId);

    /**
     * 根据系统账号id集合查询商户用户账号
     * @param sysUserIds sysUserIds
     * @return List<MerchantUserAccount>
     */
    List<MerchantUserAccountDO> listMerchantUserAccountBySysUserIds(@Param("sysUserIds") List<Long> sysUserIds);


    /**
     * 根据商户id查询可用商户用户账号(未禁用且接单开启)
     * @param merchantId merchantId
     * @return List<MerchantUserAccount>
     */
    List<MerchantUserAccountDO> listMerchantUserAccountByMerchantId(@Param("merchantId") Long merchantId);


    /**
     * 获取已开启接单的商户子账户id
     * @param merchantId merchantId
     * @return List<Long>
     */
    List<UserTeamShip> listAccountIdByMerchantId(@Param("merchantId") Long merchantId, @Param("code")String code);

    List<UserTeamShip> listReceivingStatusByMerchantId(@Param("merchantId") Long merchantId, @Param("code")String code);

    List<UserTeamShip> listReceivingStatusByTeamId(@Param("teamId") Long teamId, @Param("code")String code);

    List<Integer> isBokeUser(@Param("merchantId") Long merchantId, @Param("code")String code);

    Long listSysUserIdByMerchantId(@Param("accountId") Long accountId);

    /**
     * 获取商户子账户信息
     * @param accountIds accountIds
     * @return List<MerchantAccountResult>
     */
    List<MerchantAccountResult> listAccountInfoByAccountIds(@Param("accountIds") Set<Long> accountIds);

    /**
     * 根据id集合删除商户账户
     * @param sysUserIds sysUserIds
     * @return count
     */
    int updateMerchantAccountIsDelBySysUserIds(@Param("sysUserIds") List<Long> sysUserIds);
}
